sessionstore =require 'sessionstore'
session=require 'express-session'
express = require 'express'
memjs=require 'memjs'
app=express()
uuid=require 'uuid'

app.use(
    session(
      {
          genid:((req)->
              uuid.v1()
          ),
          secret:'keyboard cat'
      }
    )
)

app.use session {store:sessionstore.createSessionStore(
  {
    type: 'memcached'
    host: 'localhost'
    port: 11211
    prefix: 'sess-zw'
    expires: 86400
    retries: 2
    failover: false
    failoverTime: 60
    timeout: 10000
  }
)}


client=memjs.Client.create()

client.set('hello','worfdsfdsfdsfsdfdsfsdfsdfsdfsdfsdld',((err,val)->

),600
)

app.get('/',(req,res)->

  req.session.sess='session'

  console.log req.session

  res.send 'hello'
)
app.get '/memcache',(req,res)->
  debugger
  console.log req.session
  client.get('hello',(err,val)->
    console.log val
    res.send val
  )

app.listen(7001)
console.log 'the server is running'
